package com.vastio.controller;

import com.vastio.service.HelloService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author hjwStart
 * @time 2022-11-23 14:57
 * @version: 1.0
 */
@RestController
public class HelloController {

    @Autowired
    @Qualifier("helloServiceImpl")
    private HelloService helloService;

    @GetMapping("/hello")
    public String hello() {
        return helloService.hello();
    }

    @PostMapping("/login")
    public String login(String userName,String userPwd){
        Subject subject = SecurityUtils.getSubject();
        UsernamePasswordToken token = new UsernamePasswordToken(userName, userPwd);
        subject.login(token);
        return "success";
    }
}
